<?php

class Code_Decode {

	private $smb = 'zV0YX5emhJSQxsCMgBqjU4Pv7bH9RfEluLKWdAnN1Z6T8cGtwFa2piDkOoIy3r';
	private $hash = array();
	private $base;

	public function __construct() {
		$this->base = (int) strlen($this->smb);
		for ($i = 0; $i < $this->base; $i++)
			$this->hash[$this->smb[$i]] = $i;
	}

	public function getCode($n) {
		$code = '';
		while (true) {
			$code = $this->smb[$n % $this->base] . $code;
			$n=(int)($n/$this->base);
			if ($n===0)
				break;
		}
		return $code;
	}

	public function getVal($code) {
		$num = (int) 0;
		$mul = (int) 1;
		for ($i = strlen($code)-1; $i >= 0; $i--, $mul*=$this->base)
			$num+=$this->hash[$code[$i]] * $mul;
		return $num;
	}

}

/* end of code_decode.php */